package com.lishe.lishe.lishe.module.myorder.adapter;


import android.app.Activity;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.lishe.lishe.R;
import com.lishe.lishe.lishe.module.myorder.bean.TradePaybillData;
import com.lishe.lishe.lishe.utils.FullyLinearLayoutManager;

import java.util.List;

/**
 * Created by Bin
 */

public class OrderDetailAdapter extends RecyclerView.Adapter<OrderDetailAdapter.ViewHolder> {

    private Activity mContext;
    private List<TradePaybillData> mList;

    public OrderDetailAdapter(Activity context, List<TradePaybillData> list) {
        this.mList = list;
        this.mContext = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(mContext, R.layout.item_orderdetail, null);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.shopname.setText(mList.get(position).getShop_name());
        holder.recyclerview.setLayoutManager(new FullyLinearLayoutManager(mContext));
        holder.recyclerview.setAdapter(new OrderDetailGoodsAdapter(mContext, mList.get(position).getProducts()));
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        private TextView shopname;
        private RecyclerView recyclerview;


        public ViewHolder(View v) {
            super(v);
            shopname = v.findViewById(R.id.shopname);
            recyclerview = v.findViewById(R.id.recyclerview);
        }
    }
}
